package worker.config;

import com.bbq.job.WorkerConfig;
import com.bbq.utils.ConfigUtil;
import com.google.common.collect.Lists;
import java.util.List;
import org.apache.commons.lang3.StringUtils;


public class WorkerConfigImpl implements WorkerConfig {

	@Override
	public boolean getBoolean(String key) {
		return ConfigUtil.getBoolean(key);
	}

	@Override
	public String getString(String key, String orValue) {
		return ConfigUtil.getString(key, orValue);
	}

	@Override
	public List<String> getList(String key) {
		if (ConfigUtil.isList(key)) {
			return ConfigUtil.getList(key);
		} else {
			String value = ConfigUtil.getString(key, null);
			if (StringUtils.isEmpty(value)) {
				return Lists.newArrayList();
			}
			return Lists.newArrayList(value);
		}
	}

	@Override
	public Integer getInteger(String key, Integer orValue) {
		return ConfigUtil.getInteger(key, orValue);
	}
}
